﻿@page
@{ Layout = "_Layout"; }
@section Styles{
  <style>
    .el-dropdown-link {
      cursor: pointer;
      color: #409EFF;
    }
    .el-icon-arrow-down {
      font-size: 12px;
    }
    .el-icon-picture-outline {
      font-size: 22px;
      margin: 80px 0;
      color: #c0c4cc;
    }
  </style>
}

<el-row>
  <el-col :span="20">
    <el-row>
      <el-form v-on:submit.native.prevent :inline="true" :model="form" size="mini">
        <el-form-item label="搜索">
          <el-input v-model="form.keyword" placeholder="关键字"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" v-on:click="btnSearchClick">查询</el-button>
        </el-form-item>
      </el-form>
    </el-row>
  </el-col>
  <el-col align="right" :span="4">
    <el-dropdown trigger="click" v-on:command="btnDropdownClick">
      <span class="el-dropdown-link">
        {{(pageType === 'card' ? '卡片视图' : '列表视图')}} <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="card">卡片视图</el-dropdown-item>
        <el-dropdown-item command="list">列表视图</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </el-col>
</el-row>
<el-row v-if="!isSiteOnly">
  <el-tag
    v-for="group in groups"
    :key="group.id"
    type="success"
    style="cursor: pointer; margin: 0 3px 6px 0;"
    v-on:click="btnGroupClick(group.id)"
    :effect="form.groupId === group.id ? 'dark' : 'plain'">
    {{ group.groupName }}
  </el-tag>
</el-row>

<template v-if="pageType === 'card'">
  <el-row>
    <el-col :span="6" v-for="(o, index) in items" :key="o.id">
      <el-card style="margin-bottom: 15px; margin-right: 15px; height: 305px" :body-style="{ padding: '0px', textAlign: 'center' }">
        <el-link :underline="false" v-on:click="btnSelectClick(o)">
          <el-image 
            style="width: 100%; min-height: 220px; max-height:220px;"
            :src="o.url">
            <div slot="error" class="image-slot">
              <i class="el-icon-picture-outline"></i>
            </div>
          </el-image>
        </el-link>

        <div style="padding: 14px;">
          <div v-on:click="btnSelectClick(o)" style="cursor: pointer; height: 22px; font-size: 14px; overflow: hidden;">{{ o.title }}</div>
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>
<template v-else>
  <el-table
    :data="items"
    style="width: 100%">
    <el-table-column
      label="图片"
      width="150">
      <template slot-scope="scope">
        <el-link :underline="false" v-on:click="btnSelectClick(scope.row)">
          <el-image 
            style="max-height: 120px; max-width: 120px;"
            :src="scope.row.url">
            <div slot="error" class="image-slot">
              <i class="el-icon-picture-outline"></i>
            </div>
          </el-image>
        </el-link>
      </template>
    </el-table-column>
    <el-table-column label="标题">
      <template slot-scope="scope">
        <div v-on:click="btnSelectClick(scope.row)" style="cursor: pointer; height: 22px; overflow: hidden; font-size: 14px;">{{ scope.row.title }}</div>
      </template>
    </el-table-column>
    <el-table-column
      prop="createdDate"
      label="创建时间"
      width="220">
    </el-table-column>
  </el-table>
</template>

<div style="text-align: center; margin-top: 15px">
  <el-pagination
    v-on:current-change="btnPageClick"
    :current-page="form.page"
    :page-size="form.perPage"
    layout="total, prev, pager, next, jumper"
    :total="count">
  </el-pagination>
</div>

@section Scripts{
<script src="/sitefiles/assets/js/admin/common/materialLayerImageSelect.js" type="text/javascript"></script> }